package com.bupt.liutong.admin.shop.dao;

import java.util.List;

import com.bupt.liutong.admin.core.base.Ibatis;
import com.bupt.liutong.admin.shop.dto.Cart;
import com.bupt.liutong.admin.shop.dto.Prod;

public class ProdDao {
	
	private Ibatis ibatis;
	
	@SuppressWarnings("unchecked")
	public List<Prod> getProdsByPage(Prod prod){
		return (List<Prod>) ibatis.queryForPage("shop_prod.getProds", prod);
	}
	
	@SuppressWarnings("unchecked")
	public List<Prod> getHotProds(Prod prod){
		return (List<Prod>) ibatis.queryForPage("shop_prod.getHotProds", prod);
	}
	
	@SuppressWarnings("unchecked")
	public List<Prod> getProdsByTypeIdByPage(Prod prod){
		return (List<Prod>) ibatis.queryForPage("shop_prod.getProdsByTypeId", prod);
	}
	
	public Prod getProdById(int id){
		return (Prod) ibatis.queryForObject("shop_prod.getProdById", id);
	}
	
	@SuppressWarnings("unchecked")
	public List<Prod> getProfCoursesByPage(Prod prod){
		return (List<Prod>) ibatis.queryForPage("shop_prod.getProfCourses", prod);
	}
	
	@SuppressWarnings("unchecked")
	public List<Prod> getUnProfCoursesByPage(Prod prod){
		return (List<Prod>) ibatis.queryForPage("shop_prod.getUnProfCourses", prod);
	}
	
	public Integer insertProd(Prod prod){
		return (Integer) ibatis.insert("shop_prod.insertProd", prod);
	}
	
	public void updateProd(Prod prod){
		ibatis.update("shop_prod.updateProd", prod);
	}
	
	public void updateProdState(Prod prod){
		ibatis.update("shop_prod.updateProdState", prod);
	}
	
	public void updateProdHot(Prod prod){
		ibatis.update("shop_prod.updateProdHot", prod);
	}
	
	public void deleteProd(int id){
		ibatis.delete("shop_prod.deleteProd", id);
	}

	public void setIbatis(Ibatis ibatis) {
		this.ibatis = ibatis;
	}
}
